#ifndef LEMC_GUIELEMENT_H
#define LEMC_GUIELEMENT_H

#include <string>

/*
* An abstact base class for gui elements that can react to input.
*/
class GuiElement
{
protected:
	// The id of the element. Should be unique.
	std::string m_id;

	// The position of the gui element.
	int m_x, m_y;

	// The dimensions of the gui element.
	int m_size_x, m_size_y;

public:
	/*
	* Creates the gui element by setting the attributes.
	*
	* @param id The id of the element, should be unique.
	* @param x The x position of the upper left corner of the element.
	* @param y The y position of the upper left corner of the element.
	* @param size_x Horizontal size of the element.
	* @param size_y Vertical size of the element.
	*/
	GuiElement(std::string id, int x, int y, int size_x, int size_y)
		: m_id(id), m_x(x), m_y(y), m_size_x(size_x), m_size_y(size_y)
	{
	}

	virtual ~GuiElement()
	{
	}

	/*
	* Tell the element that the primary mouse button was released.
	* 
	* @param x The x position of the mouse when this happened.
	* @param y The y position of the mouse when this happened.
	*/
	virtual void PrimaryMouseButtonUp(int x, int y) {}

	/*
	* Tell the element that the primary mouse button was pressed.
	* 
	* @param x The x position of the mouse when this happened.
	* @param y The y position of the mouse when this happened.
	*/
	virtual void PrimaryMouseButtonDown(int x, int y) {}

	/*
	* Tell the element that the secondary mouse button was released.
	* 
	* @param x The x position of the mouse when this happened.
	* @param y The y position of the mouse when this happened.
	*/
	virtual void SecondaryMouseButtonUp(int x, int y) {}

	/*
	* Tell the element that the secondary mouse button was pressed.
	* 
	* @param x The x position of the mouse when this happened.
	* @param y The y position of the mouse when this happened.
	*/
	virtual void SecondaryMouseButtonDown(int x, int y) {}

	/*
	* Tell the element that the mouse position changed.
	* 
	* @param x The x position of the mouse when this happened.
	* @param y The y position of the mouse when this happened.
	*/
	virtual void MouseAxisChange(int x, int y) {}

	/*
	* Tell the element a character was typed on the keyboard, or a character was auto-repeated.
	* 
	* @param keycode The keycode of the last physical key that was pressed.
	* @param unichar The code of the character.
	*/
	virtual void CharEntered(int keycode, int unichar) {}

	/*
	* Update the element.
	*/
	virtual void Update() {}

	/*
	* Draw the element.
	*/
	virtual void Draw() {}

	virtual void ChangePosition(int x, int y)
	{
		m_x = x;
		m_y = y;
	}

	virtual void MovePosition(int x, int y)
	{
		m_x += x;
		m_y += y;
	}

	virtual std::string id() { return m_id; }
};

#endif